package com.ruoyi.project.sales.orders.search.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.sales.orders.search.domain.Orders;
import com.ruoyi.project.sales.orders.search.service.IOrderSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/sales/orders/search")
public class SearchController extends BaseController {

    private String prefix = "sales/orders/search";

    @Autowired
    private IOrderSearchService orderService;


    @GetMapping()
    public String search()
    {
        return prefix + "/search";
    }

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Orders orders)
    {
        startPage();
        List<Orders> list = new ArrayList<>();
        list = orderService.selectOrderList(orders);
        return getDataTable(list);
    }
}
